package com.ty.springbootmybatisplusdruid.controller;

import com.ty.springbootmybatisplusdruid.pojo.News;
import com.ty.springbootmybatisplusdruid.service.NewsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * HelloController
 *
 * @aurhor Administrator  whs
 * @since 2024/9/10
 */
@RestController
@RequestMapping("/news")
public class HelloController {

    @Resource
    private NewsService newsService;


    @GetMapping("/list")
    public Object newsList() {
        List<News> list = newsService.list();
        for (News news : list) {
            System.out.println(news);
        }
        return list;
    }

    /**
     * 删除新闻
     *
     * @param id
     * @return
     */
    @GetMapping("/news/del/{id}")
    public boolean newsDel(@PathVariable("id") Integer id) {
        return newsService.removeById(id);
    }


}